//获取数量
function getZhuangNum(dataArr) {
    var count = 0;
    for (var i = 0; i < dataArr.length; i++) {
        var result = dataArr[i];
        if (result == "庄") count++;
    }
    return count;
}

//获取最大值种类及数量
function getMax(dataArr) {
    var map = {}
    var zhuangNum = getZhuangNum(dataArr);
    var xianNum = dataArr.length - zhuangNum;
    if (xianNum > zhuangNum) {
        map["闲"] = xianNum;
    } else {
        map["庄"] = zhuangNum;
    }
    return map;
}

function tmpArr(dataArr, size) {
    var tmp = dataArr.slice(0, size);
    ;
    return tmp;
}

function writeMax(dataArr, dui) {
    var map = getMax(dataArr);
    for (var key in map) {
        var data = dataArr[dataArr.length - 1];
        var data2 = dataArr[dataArr.length - 2];
        if (data == key) {
            dui.push("对");
            return "<span style='color: red'>" + data + "</span>"
        } else {
            dui.push("错");
            return data;
        }
    }
}

function suitMax(dataArr, key) {
    var hc = "";
    var dui = [];
    for (var i = 0; i < dataArr.length; i++) {
        //当前值之前，规则得匹配程度
        var tmp = tmpArr(dataArr, i + 1);
        if (i % 3 == 0) {
            hc += "<br/>" + writeMax(tmp, dui);//dui[i]
        } else {
            hc += writeMax(tmp, dui) + "";//dui[i]
        }

    }
    return hc;
}